<?php

/**
 * This file is part of the Framework03 PHP framework.
 * @package Framework03
 * @author Walter Tamboer
 */

// Let's get the root directory, this will be useful when setting all the paths.
$root = dirname(dirname(__FILE__));

// The include paths so that all application items can be found.
set_include_path(get_include_path() . PATH_SEPARATOR . $root . '/../library');

// Make sure that PHP actually shows the errors.
ini_set('display_errors', true);

// Also make sure that PHP shows startup errors.
ini_set('display_startup_errors', true);

// We want to show all errors including strict errors because we don't make mistakes.
error_reporting(E_ALL | E_STRICT);

// We want automatic loading of classes because we're lazy.
require_once 'FW/Loader.php';
FW_Loader::startAutoLoading();

$form = new FW_Form();

$element = $form->createElement('text', 'fieldName');
$element->setLabel('Field:');
$element->setRequired(true);
$form->addElement($element);

$element = $form->createElement('submit', 'submit');
$element->setValue('Submit');
$form->addElement($element);

if ($_SERVER[ 'REQUEST_METHOD' ] == 'POST')
{
    if ($form->isValid($_POST))
    {
        echo 'Valid';
    }
    else
    {
        echo 'Invalid';
    }
}

echo $form;